#pragma once

#include <pthread.h>
#include "Mutex.h"

namespace zmh
{
    class Cond
    {
    public:
        Cond()
        {
            pthread_cond_init(&_cond, nullptr);
        }
        ~Cond()
        {
            pthread_cond_destroy(&_cond);
        }
        void wait(Mutex &Mutex)
        {
            pthread_cond_wait(&_cond, Mutex.get_mutex());
        }
        void signal()
        {
            pthread_cond_signal(&_cond);
        }
        void broadcast()
        {
            pthread_cond_broadcast(&_cond);
        }

    private:
        pthread_cond_t _cond;
    };
}